package com.dindang.propertyfee.mvp.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dindang.propertyfee.R;
import com.dindang.propertyfee.di.component.DaggerPropertyFeeComponent;
import com.dindang.propertyfee.di.module.PropertyFeeModule;
import com.dindang.propertyfee.mvp.contract.PropertyFeeContract;
import com.dindang.propertyfee.mvp.presenter.PropertyFeePresenter;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import static com.jess.arms.utils.Preconditions.checkNotNull;


public class PropertyFeeFragment extends BaseFragment<PropertyFeePresenter> implements PropertyFeeContract.View {

    View mViewSearch;
    RecyclerView mRvExpire;
    TextView mTvLateHome;
    TextView mTvMore;
    RecyclerView mListview;
    View view;

    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {
        DaggerPropertyFeeComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .propertyFeeModule(new PropertyFeeModule(this))
                .build()
                .inject(this);
    }

    @Override
    public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.propertyfee_fragment_property_fee, container, false);
        return view;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mViewSearch = view.findViewById(R.id.propertyfee_view_search);
        mRvExpire = view.findViewById(R.id.propertyfee_rv_expire);
        mTvLateHome = view.findViewById(R.id.propertyfee_tv_late_home);
        mTvMore = view.findViewById(R.id.propertyfee_tv_more);
        mListview = view.findViewById(R.id.propertyfee_listview);
        mPresenter.init();
    }

    @Override
    public void setData(@Nullable Object data) {
        mPresenter.setData(data);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {

    }

    @Override
    public View getViewSearch() {
        return mViewSearch;
    }

    @Override
    public RecyclerView getRvExpire() {
        return mRvExpire;
    }

    @Override
    public TextView getTvLateHome() {
        return mTvLateHome;
    }

    @Override
    public TextView getTvMore() {
        return mTvMore;
    }

    @Override
    public RecyclerView getListview() {
        return mListview;
    }

    @Override
    public Fragment getFragment() {
        return this;
    }
}
